package com.bestcem.xm.ticket.config;

import com.bestcem.xm.ticket.enums.TicketNotifyConfigEventEnum;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 工单钉钉通知配置
 *
 * @author XiaoYunSong <ys.xiao@idiaoyan.com>
 * @version v1.0
 * @date 2021/12/1 18:28
 */
@Data
@Component
@ConfigurationProperties(prefix = "app.ticket.notify-template.dingtalk")
public class TicketDingTalkProperties {
    /**
     * 预警通知模板id
     */
    private String onlyNotify = "690e7d9ce1264b8f92da8ee1a5b4e140";
    /**
     * 收到工单通知模板id
     */
    private String createdTicket = "f3a192dcb8524ef7ac1f8f9c95c129fd";
    /**
     * 逾期提醒通知模板id
     */
    private String followRemind = "0defcb3c46ce467da9bd8cf42b14932f";
    /**
     * 工单逾期通知模板id
     */
    private String followOverdue = "13c9eb7a86ee4c1195d6d28f49a23c6d";

    /**
     * 获取钉钉对应事件通知模板
     *
     * @param event 通知事件
     * @return 模板id
     * @author XiaoYunSong <ys.xiao@idiaoyan.com>
     * @date 2021/12/1 18:40
     */
    public String getTemplateId(TicketNotifyConfigEventEnum event) {
        if (TicketNotifyConfigEventEnum.ONLY_NOTIFY.equals(event)) {
            return onlyNotify;
        }
        if (TicketNotifyConfigEventEnum.CREATED_TICKET.equals(event)) {
            return createdTicket;
        }
        if (TicketNotifyConfigEventEnum.FOLLOW_REMIND.equals(event)) {
            return followRemind;
        }
        if (TicketNotifyConfigEventEnum.FOLLOW_OVERDUE.equals(event)) {
            return followOverdue;
        }
        return null;
    }
}
